﻿using MediatR;
using UserLicense.Applicationes.Command;
using UserModels;
using UserModels.DTO;
using UserRepositorys.Intface;

namespace UserLicense.Applicationes.CommandHandler
{
    public class MenuListCommandHandler : IRequestHandler<MenuListCommand, List<MenuTree>>
    {
        private readonly IMenuRepository _menuRepository;
        public MenuListCommandHandler(IMenuRepository menuRepository)
        {
            _menuRepository = menuRepository;
        }

        /// <summary>
        /// 第一级菜单
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<MenuTree>> Handle(MenuListCommand request, CancellationToken cancellationToken)
        {
            return await _menuRepository.GetMenus(request.id,request.accountId);
        }
    }
}
